package com.sftz.modules.minapp.hotSeriesCoures.service;

import java.util.HashMap;
import java.util.Map;

import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;

import com.sftz.assets.entities.SeriesCoursesEntity;
import com.sftz.assets.enums.SerCourseStatusEnum;
import com.sftz.assets.enums.YesOrNoEnum;
import com.sftz.modules.minapp.hotSeriesCoures.dto.serCourseDto;
import com.uxuexi.core.db.util.DbSqlUtil;
import com.uxuexi.core.web.base.service.BaseService;

@IocBean
public class HotSerirsecourselViewService extends BaseService<SeriesCoursesEntity> {
	private static final Log log = Logs.get();

	/*
	 * 查询系列课程列表
	 * */
	public Object hotSerCourseList(Integer pageNumber, Integer pageSize) {
		Map<String, Object> map = new HashMap<String, Object>();
		//查询系列课程数量
		int count = (int) selctSerCourseCount();
		//计算起始页
		int start = (pageNumber - 1) * pageSize;
		//查询学历机构全部系列课程列表 
		Sql sql = Sqls.create(sqlManager.get("minapp_hotSerCourse_List"));
		sql.setParam("isDelete", YesOrNoEnum.NO.intKey());
		sql.setParam("status", SerCourseStatusEnum.ON.intKey());
		sql.setParam("start", start);
		sql.setParam("end", pageSize);

		map.put("serCourse", DbSqlUtil.query(dbDao, serCourseDto.class, sql));
		map.put("count", count);
		map.put("pageNumber", pageNumber);
		map.put("pageSize", pageSize);
		return map;

	}

	/*
	 * 查询系列课程数量
	 * */
	public Object selctSerCourseCount() {
		//查询系列课程总数量
		Sql countSql = Sqls.create(sqlManager.get("minapp_hotSerCourse_Count"));
		countSql.setParam("isDelete", YesOrNoEnum.NO.intKey());
		countSql.setParam("status", SerCourseStatusEnum.ON.intKey());
		int count = DbSqlUtil.fetchInt(dbDao, countSql);
		return count;

	}

}